import 'package:flutter/material.dart';
import 'package:im_flutter_sdk_example/jsonserialize/moment/data.dart';
import 'package:im_flutter_sdk_example/utils/global.dart';

class MomentProvider with ChangeNotifier {
  MomentModel _momentModel;

  get data => _momentModel;

  /// 初始化
  loadMoment() async {
    var result = await G.req.moment.getMoments();
    if (result.data['status'] == 1) {
      print('刷新了啊嗷嗷 啊    ');
      _momentModel = MomentModel.fromJson(result.data['data']);
    }
    notifyListeners();
  }

  // 发布动态
  publish(String content, List<String> pictures) async {
    await G.req.group.momentPublish(content: content, pictures: pictures);
    await loadMoment();
  }
}
